<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta name="generator" content="Doxygen 1.8.13">
<title>OpenCV:OpenCV安装概述</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon">
<link href="../../tabs.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css">
<link href="../../stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d9/df8/tutorial_root.html">OpenCV Tutorials</a></li><li class="navelem"><a class="el" href="../../df/d65/tutorial_table_of_content_introduction.html">Introduction to OpenCV</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">OpenCV安装概述</div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>目录</h3>
<ul><li class="level1"><a href="#tutorial_general_install_prebuilt">Prebuilt version(预构建版本)</a><ul><li class="level2"><a href="#tutorial_general_install_prebuilt_core">OpenCV核心团队的软件包</a></li>
<li class="level2"><a href="#tutorial_general_install_prebuilt_thirdparty">第三方软件包</a></li>
</ul>
</li>
<li class="level1"><a href="#tutorial_general_install_sources">从源代码生成</a><ul><li class="level2"><a href="#tutorial_general_install_sources_0">步骤0:先决条件</a></li>
<li class="level2"><a href="#tutorial_general_install_sources_1">步骤1:获取软件源</a></li>
<li class="level2"><a href="#tutorial_general_install_sources_2">第2步:配置</a></li>
<li class="level2"><a href="#tutorial_general_install_sources_3">步骤3:构建</a></li>
<li class="level2"><a href="#tutorial_general_install_sources_4">步骤3:安装</a></li>
</ul>
</li>
</ul>
</div>
<div class="textblock"><p><b>下一个教程:</b> <a class="el" href="../../db/d05/tutorial_config_reference.html">OpenCV configuration options reference(OpenCV配置选项参考)</a></p>
<p>在您的计算机上安装OpenCV有两种方法:下载平台的预构建版本或从源代码处编译.</p>
<h1><a class="anchor" id="tutorial_general_install_prebuilt"></a>Prebuilt version(预构建版本)</h1>
<p>在许多情况下,您可以找到满足您需求的预构建版本的OpenCV.</p>
<h2><a class="anchor" id="tutorial_general_install_prebuilt_core"></a>OpenCV核心团队的软件包</h2>
<p>Android、iOS和Windows的软件包使用默认参数和最新的编译器构建,每个版本都会发布,它们不包含<em>opencv_contrib </em> modules.</p>
<ul>
<li>GitHub releases:<a href="https://github.com/opencv/opencv/releases">https://github.com/opencv/opencv/releases</a></li>
<li>SourceForge.net:<a href="https://sourceforge.net/projects/opencvlibrary/files/">https://sourceforge.net/projects/opencvlibrary/files/</a></li>
</ul>
<h2><a class="anchor" id="tutorial_general_install_prebuilt_thirdparty"></a>Third-party packages(第三方软件包)</h2>
<p>其他组织和人员维护自己的OpenCV二进制发行版.例如:</p>
<ul>
<li>流行Linux发行版中的系统包(<a href="https://pkgs.org/search/?q=opencv">https://pkgs.org/search/?q=opencv</a>)</li>
<li>PyPI (<a href="https://pypi.org/search/?q=opencv">https://pypi.org/search/?q=opencv</a>)</li>
<li>Conda (<a href="https://anaconda.org/search?q=opencv">https://anaconda.org/search?q=opencv</a>)</li>
<li>Conan (<a href="https://github.com/conan-community/conan-opencv">https://github.com/conan-community/conan-opencv</a>)</li>
<li>vcpkg (<a href="https://github.com/microsoft/vcpkg/tree/master/ports/opencv">https://github.com/microsoft/vcpkg/tree/master/ports/opencv</a>)</li>
<li>NuGet (<a href="https://www.nuget.org/packages?q=opencv">https://www.nuget.org/packages?q=opencv</a>)</li>
<li>Brew (<a href="https://formulae.brew.sh/formula/opencv">https://formulae.brew.sh/formula/opencv</a>)</li>
<li>Maven (<a href="https://search.maven.org/search?q=opencv">https://search.maven.org/search?q=opencv</a>)</li>
</ul>
<h1><a class="anchor" id="tutorial_general_install_sources"></a>Build from sources(从源代码生成)</h1>
<p>可能现有的二进制软件包不适用于您的用例,那么您必须自己构建OpenCV的定制版本.本节提供了构建过程的高级概述,请参阅教程以了解具体平台的实际构建说明.</p>
<p>OpenCV uses<a href="https://cmake.org/">CMake</a>构建配置和构建的管理系统,因此本节主要描述用CMake构建软件的一般过程.</p>
<h2><a class="anchor" id="tutorial_general_install_sources_0"></a>步骤0:先决条件</h2>
<p>安装C++编译器和构建工具.在*NIX平台上,它通常是GCC/G++或Clang编译器和Make或Ninja构建工具.在Windows上,它可以是visualstudioide或MinGW-w64编译器.Android NDK中提供了Android的原生工具链.XCode IDE用于为OSX和iOS平台构建软件.</p>
<p>从官方网站或其他来源安装CMake.</p>
<p>获取其他第三方依赖项:具有解码视频或显示GUI元素等额外功能的库；提供选定算法的优化实现的库；用于生成文档和其他附加功能的工具.检查<a class="el" href="../../db/d05/tutorial_config_reference.html">OpenCV configuration options reference</a>获取可用选项和相应的依赖项.</p>
<h2><a class="anchor" id="tutorial_general_install_sources_1"></a>步骤1:获取软件源</h2>
<p>典型的软件项目由一个或多个代码库组成. OpenCV有两个代码库:<em>opencv</em>具有稳定且积极支持的算法和<em> opencv_contrib </em>包含实验性和非自由(专利)算法；以及一个包含测试数据的存储库:<em> opencv_extra </em>.</p>
<p>您可以下载存储库的快照,其形式为存档或具有完整历史记录的克隆存储库.</p>
<p>要下载快照存档,请执行以下操作:</p>
<ul>
<li>Go to<a href="https://github.com/opencv/opencv/releases">https://github.com/opencv/opencv/releases</a>并从任何版本下载“源代码”存档.</li>
<li>(可选)转到<a href="https://github.com/opencv/opencv_contrib/releases">https://github.com/opencv/opencv_contrib/releases</a>并下载“源代码”存档,其版本与<em> opencv </em></li>
<li>(可选)转到<a href="https://github.com/opencv/opencv_extra/releases">https://github.com/opencv/opencv_extra/releases</a>并下载“源代码”存档,其版本与<em> opencv </em></li>
<li>把所有的档案打包到某个地方</li>
</ul>
<p>要克隆存储库,请在console中运行以下命令(<em>git</em> <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">must be installed(git 必须安装)</a>):</p>
<div class="fragment"><div class="line">git clone https://github.com/opencv/opencv</div><div class="line">git -C opencv checkout &lt;some-tag&gt;</div><div class="line"></div><div class="line"># optionally</div><div class="line">git clone https://github.com/opencv/opencv_contrib</div><div class="line">git -C opencv_contrib checkout &lt;same-tag-as-opencv&gt;</div><div class="line"></div><div class="line"># optionally</div><div class="line">git clone https://github.com/opencv/opencv_extra</div><div class="line">git -C opencv_extra checkout &lt;same-tag-as-opencv&gt;</div></div><!-- fragment --><dl class="section note"><dt>Note(注意)</dt><dd>如果要使用多个存储库构建软件,请确保所有组件彼此兼容.对于OpenCV,这意味着<em>opencv</em>和<em>opencv_contrib</em>必须在同一标记处签出存储库,或者从同一版本下载所有快照存档.</dd>
<dd>在选择要下载的版本时,请考虑您的目标平台和开发工具版本,最新版本的OpenCV可能会在非常旧的编译器上出现构建问题,反之亦然.我们建议使用最新版本和最新的OS/编译器组合.</dd></dl>
<h2><a class="anchor" id="tutorial_general_install_sources_2"></a>第2步:配置</h2>
<p>在这一步,CMake将验证所有必要的工具和依赖项是否可用并与库兼容,并为所选的构建系统生成中间文件.它可以是makefile、IDE项目和解决方案等.通常在新创建的构建目录中执行此步骤:</p><div class="fragment"><div class="line">cmake -G&lt;generator&gt; &lt;configuration-options&gt; &lt;source-directory&gt;</div></div><!-- fragment --><dl class="section note"><dt>Note(注意)</dt><dd><code>cmake-gui</code>应用程序允许使用图形用户界面查看和修改可用选项.看到了吗<a href="https://cmake.org/runningcmake/">https://cmake.org/runningcmake/</a>详情.</dd></dl>
<h2><a class="anchor" id="tutorial_general_install_sources_3"></a>步骤3:构建</h2>
<p>在构建过程中,源文件被编译成对象文件,这些文件被链接在一起或以其他方式组合到库和应用程序中.可以使用通用命令运行此步骤:</p><div class="fragment"><div class="line">cmake --build &lt;build-directory&gt; &lt;build-options&gt;</div></div><!-- fragment --><p>... 或者可以直接调用底层生成系统:</p><div class="fragment"><div class="line">make</div></div><!-- fragment --><h2><a class="anchor" id="tutorial_general_install_sources_4"></a>步骤3:安装</h2>
<p>在安装过程中,生成目录中的生成结果和其他文件将复制到安装位置.默认安装位置为<code>/usr/local</code>在UNIX和<code>C:/Program Files</code>在窗户上.在配置步骤中,可以通过设置<code>CMAKE_INSTALL_PREFIX</code>选项.要执行安装,请运行以下命令:</p><div class="fragment"><div class="line">cmake --build &lt;build-directory&gt; --target install &lt;other-options&gt;</div></div><!-- fragment --><dl class="section note"><dt>注意</dt><dd>这个步骤是可选的,OpenCV可以直接从build目录中使用.</dd>
<dd>如果安装根目录是受保护的系统目录,则安装过程必须以超级用户或管理员权限(例如.<code>sudo cmake ...</code>).</dd></dl>
<div class="fragment"><div class="line">Translation revision: zhengshizeng</div></div>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"><address class="footer"><small>2021年4月2日星期五11:36:36为OpenCV生成 zsz<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen">
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
